import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
import TreeTable from 'vue-table-with-tree-grid'

import axios from 'axios'
import instance from './network/request'
import './assets/css/global.css'
import '../fonts/iconfont.css'

import VueQuillEditor from 'vue-quill-editor'

import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme

Vue.config.productionTip = false
Vue.prototype.$http = axios

Vue.use(instance)
Vue.use(VueQuillEditor)
// 注册名称，要注册的组件
Vue.component('tree-table', TreeTable)

// 声明一个全局过滤器
Vue.filter('dateFormat', function(timer) {
  const dayTime = new Date(timer)

  const year = dayTime.getFullYear()
  // 由于此时月份可能不足10个月  我们使用0字符串拼接到月份上
  // 使用字符串函数的padStart() 方法来补全月份
  // 第一个参数代表需要补全的长度
  // 第二个参数代表如果不到不全的长度就会在前面拼接一个字符串0
  const month = (dayTime.getMonth() + 1 + '').padStart(2, '0')
  const day = (dayTime.getDate() + '').padStart(2, '0')

  const hours = (dayTime.getHours() + '').padStart(2, '0')
  const minutes = (dayTime.getMinutes() + '').padStart(2, '0')
  const seconds = (dayTime.getSeconds() + '').padStart(2, '0')

  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
})

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')